﻿Imports System.IO
Imports Clases
Public Class Gestion

    Public Sub New()

    End Sub

    ' ================================== Cargar es una función o un subprograma

    Public Sub Cargar(ByVal nombre As String)
        Dim Contenido() As String
        Dim cont As Integer = 0
        If Not File.Exists(My.Application.Info.DirectoryPath & "\Datos\" & nombre & ".txt") Then File.Create(My.Application.Info.DirectoryPath & "\Datos\" & nombre & ".txt")
        Dim ficR As StreamReader
        Select Case nombre
            Case "Clientes"
                Try
                    ficR = New StreamReader(My.Application.Info.DirectoryPath & "\Datos\" & nombre & ".txt")
                    Dim datos() As String
                    Dim linea As String
                    Do Until ficR.EndOfStream
                        linea = ficR.ReadLine()
                        datos = linea.Split("*")
                        Dim miCliente As Cliente
                        datos(0) = miCliente.Nombre
                        datos(1) = miCliente.Contraseña
                        datos(2) = miCliente.Email
                        datos(3) = miCliente.NumeroTarjeta
                        datos(4) = miCliente.FechaCaducidad



                    Loop
                    '  Return Contenido
                Catch ex As Exception


                End Try

            Case "Productos"
                Try
                    ficR = New StreamReader(My.Application.Info.DirectoryPath & "\Datos\" & nombre & ".txt")
                    Dim datos() As String
                    Dim linea As String
                    Do Until ficR.EndOfStream
                        linea = ficR.ReadLine()
                        datos = linea.Split("*")
                        Dim miComida As Comida
                        ' miComida = New Comida(datos(0), datos(1), datos(2), datos(3))
                        



                    Loop
                    '  Return Contenido
                Catch ex As Exception


                End Try

        End Select
        
    End Sub


    Public Sub Grabar(ByVal nombre As String)
        Dim ficW As StreamWriter
        ficW = New StreamWriter(My.Application.Info.DirectoryPath & "\Datos\" & nombre & ".txt")


    End Sub

    Public Sub Crear(ByVal nombre As String)
        If File.Exists(My.Application.Info.DirectoryPath & "\Datos\" & nombre & ".txt") Then Exit Sub Else File.Create(My.Application.Info.DirectoryPath & "\Datos\" & nombre & ".txt")
    End Sub

End Class
